package com.hh.commen.controller;

import com.hh.commen.service.CommonService;
import com.hh.store.service.StoreService;
import com.hh.utils.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author Hanh
 * @date 2023/8/16 17:36s
 */
@RestController
@RequestMapping("common")
@CrossOrigin
public class CommenController {

    @Autowired
    private StoreService storeService;


    @Autowired
    private CommonService commonService;
    /**
     *根据库区code查看库位
     * @param areaCode
     * @return
     */
    @GetMapping("store")
    public ResultVo getStoreByAreaCode(@RequestParam("areaCode") String areaCode) {
        return storeService.getStoreByAreaCode(areaCode);
    }

    /**
     * 根据法人code拿到库房信息
     * @param legalpersonCode
     * @return
     */
    @GetMapping("storeRoomSee")
    public ResultVo getStoreRoomByLegalPersonCode(@RequestParam("legalpersonCode") String legalpersonCode) {
        return storeService.getStoreRoomByLegalPersonCode(legalpersonCode);
    }

    /**
     * 根据库房code拿到库区的信息
     * @param storeRoomCode
     * @return
     */
    @GetMapping("storeAreaSee")
    public ResultVo getStoreAreaByRoomCode(@RequestParam("storeRoomCode") String storeRoomCode) {
        return storeService.getStoreAreaByRoomCode(storeRoomCode);
    }

    /**
     * 地区下拉列表功能
     * @return
     */
    @GetMapping("region")
    public ResultVo region() {
        return commonService.region();
    }

    /**
     * 国家下拉框接口
     * @param regionCode
     * @return
     */
    @GetMapping("country")
    public ResultVo country(@RequestParam("regionCode") String regionCode) {
        return commonService.country(regionCode);
    }

    /**
     * 省下拉框接口
     * @param countryCode
     * @return
     */
    @GetMapping("province")
    public ResultVo province(@RequestParam("countryCode") String countryCode) {
        return commonService.province(countryCode);
    }

    /**
     * 市下拉框接口
     * @param provinceCode
     * @return
     */
    @GetMapping("city")
    public ResultVo city(@RequestParam("provinceCode") String provinceCode) {
        return commonService.city(provinceCode);
    }

    /**
     * 县区下拉框接口
     * @param cityCode
     * @return
     */
    @GetMapping("county")
    public ResultVo county(@RequestParam("cityCode") String cityCode) {
        return commonService.county(cityCode);
    }


    /**
     * 库区属性下拉
     * @return
     */
    @GetMapping("attribute")
    public ResultVo county() {
        return commonService.getAllAttribute();
    }
}
